<?php
require_once 'includes/config.php';

if(!empty($_POST['submit']))
{
$email=$_POST['email'];
$cfmCode=$_POST['confirmCode'];
$sqlSelUsrTmp="SELECT * FROM tbl_temp_user WHERE 
      	email='$email' and confirmation_code ='$cfmCode'";
$rstSelUsrTmp=mysql_query($sqlSelUsrTmp);
$noSelUsrTmp=mysql_num_rows($rstSelUsrTmp);

if($noSelUsrTmp>0)
{
$rowSelUsrTmp=mysql_fetch_array($rstSelUsrTmp);
extract($rowSelUsrTmp);
  $sqlSelUsr="SELECT email FROM tbl_users WHERE email='$email'";
  $rstSelUsr=mysql_query($sqlSelUsr);
  $noSelUsr=mysql_num_rows($rstSelUsr);

  if($noSelUsr==0) 
  {
   $sqlInsUsr="INSERT INTO tbl_users SET   
  				 	username='".$username."',
					password='".$password."',
					user_type=".$user_type.",
					first_name='".$first_name."',
					last_name='".$last_name."',
					address_line_1='".$address_line_1."',
					address_line_2='".$address_line_2."',
					city='".$city."',
					state='".$state."',
					country='".$country."',
					zip='".$zip."',
					phone_number_1='".$phone_number_1."',
					email='".$email."',
				    secret_question='".$secret_question."',
					secret_answer='".$secret_answer."',
					dob='".$dob."',
					created_date='".$created_date;
					
	if($user_type=='1' || $user_type=='2')
	{
      $sqlInsUsr=$sqlInsUsr.", status=1 ";
	  }
  else if($user_type=='3')
  {
    $sqlInsUsr=$sqlInsUsr.", status=2 ,business_name='".$business_name."' ,phone_number_2='".$phone_number_2."'";
	}
	else if($user_type=='5')
	{
	$sqlInsUsr=$sqlInsUsr.", status=2 ,business_name='".$business_name."' ,phone_number_2='".$phone_number_2."'";
	}
	echo $sqlInsUsr;
	die();
	$rstInsUsr = mysql_query($sqlInsUsr)or die(mysql_error());
	$insertedId = mysql_insert_id(); 
	if($insertedId>0)
	{
	 if($user_type==3)
	 {
	 $msg="<font face=verdana size=2 color='#005B00'><b>There is a 1-3 business day wait for verification purposes, but you can start creating your inventory list today! Once you are verified as a Swapen Merchant, your inventory list will go online!</b></font>";
	 }
	 else
	 {
	 $msg="<font face=verdana size=2 color='#005B00'><b>Your account successfully confirmed, <a href='http://genisofttechnologies.com/php1/swapen/index.php?signin'>Signin here</a> to continue.</b></font>";
	 }
	}
}
else
    $msg = "<font face=verdana size=2 color='#FF0000'><b>This email id already exist in another account, enter valid one.</b></font>";
}
else
	$msg = "<font face=verdana size=2 color='#FF0000'><b>Invalid email address or confirmation code.</b></font>";
}
?>
<div id='panel'>
<form name="frmConfirmMember" id="frmConfirmMember" method="post" action="<?php echo $_SERVER['php_self']?> " onsubmit="return validateConfirmMember()">
<input type="hidden" name="confirmMemberKey" id="confirmMemberKey" />
<table width="100%" border="0" class="contentForm"  cellpadding="0" cellspacing="0">
  <tr>
    <td width="35%" class="contentHeader"><h2>Confirm registration for Swapen.com</h2></td>
  </tr>
  <tr>
    <td>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td></td>
    <td  height="10"></td>
  </tr>
  <tr>
    <td width="2%"></td>
    <td width="98%"  height="16"><div id="messageArea"><?php if(isset($msg))
											echo "<b>".$msg."</b>";
										
		?></div></td>
  </tr>
  <tr>
    <td></td>
    <td  height="10"></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><div id="lblEmail">Email Address</div>
        <input type="text" name="email" id="email"></td>
  </tr>
  <tr>
    <td></td>
    <td  height="10"></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><div id="lblConfirmCode">Confirm code</div>
        <input type="text" name="confirmCode" id="confirmCode"></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input type="submit" name="submit" id="submit" value="Confirm" /></td>
  </tr>
  <tr>
    <td></td>
    <td  height="10"></td>
  </tr>
</table>
</td>
</tr>
</table>
</form>
</div>